#include <opencv2/opencv.hpp>
#include <string>

using namespace std;

extern "C" void extractROI(unsigned char *palmprint, unsigned char *roi);

int main() {
    const string pid = "0023";
    const string iid = "03";
    string path_in = "/home/yjy/dataset/CASIA-PalmprintV1/" + pid + "/" + pid + "_m_l_" + iid + ".jpg";
    string path_out = "/home/yjy/dataset/CASIA-ROI-Zhang/" + pid + "_m_l_" + iid + ".jpg";
    int roi_size = 128;
    uchar *roi_data = new uchar[roi_size * roi_size];
    cv::Mat roi = cv::Mat::zeros(roi_size, roi_size, CV_8U);

    cv::Mat img = cv::imread(path_in, cv::IMREAD_GRAYSCALE);
    extractROI(img.data, roi_data);
    roi.data = roi_data;
    cv::imwrite(path_out, roi);
    return 0;
}
